using System.Collections.Generic;
using SuperSDKV4;
using Yoozoo.Mars.SDK;

namespace Yoozoo.Gameplay.SDK
{
    /// <summary>
    /// 之前设计将SupserSDK的接入代码都放到了ResourceUpdate目录下，导致代码无法热更
    /// 这里将之前需要热更的接口在这里重新实现一遍，以便热更
    /// </summary>
    public class SuperSDKManagerHotUpdate
    {
        /// <summary>
        /// 打开一个web界面
        /// </summary>
        /// <param name="openUrl"></param>
        /// <param name="ticket"></param>
        /// <param name="gameId"></param>
        /// <param name="opid"></param>
        /// <param name="vipGrade"></param>
        /// <param name="serverId"></param>
        /// <param name="serverName"></param>
        /// <param name="roleId"></param>
        /// <param name="roleName"></param>
        /// <param name="level"></param>
        /// <param name="lang"></param>
        public static void SuperSdkOpenH5View(string openUrl, string ticket, string vipGrade, string serverId,
            string serverName, string roleId, string roleName, string level)
        {
            OpenH5View(
                openUrl, 
                ticket, 
                SDKPlatform.GetInstance().GetGameId(), 
                SDKPlatform.GetInstance().GetopId(), 
                vipGrade, 
                serverId, 
                serverName, 
                roleId, 
                roleName, 
                level, 
                SDKPlatform.GetInstance().GetLanguage());
        }
        
        public static void OpenH5View(string openUrl, string ticket, string gameId, string opid, string vipGrade, string serverId,
            string serverName, string roleId, string roleName, string level, string lang)
        {
            Dictionary<string, object> paramsDic = new Dictionary<string, object>();
            paramsDic.Add("h5url", openUrl);// H5页面地址
            paramsDic.Add("ticket", ticket);  //登录返回的ticket
            paramsDic.Add("gameId", gameId);
            paramsDic.Add("opid", opid);
            paramsDic.Add("vip_grade", vipGrade);
            paramsDic.Add("server_id", serverId);
            paramsDic.Add("server_name", serverName);
            paramsDic.Add("role_id", roleId);
            paramsDic.Add("role_name", roleName);
            paramsDic.Add("level", level);

            Dictionary<string, object> extendDic = new Dictionary<string,object>();
            extendDic.Add("lang_key", lang);
            extendDic.Add("avatar", "");
            extendDic.Add("ingame_siteid", "1");
            extendDic.Add("showToolbar", "1");
            extendDic.Add("orientation", "1"); //要求必须竖屏
            paramsDic.Add("extend", extendDic);// 扩展参数，可不传

            SuperSDK.getInstance().Invoke("h5sdk", "openH5View", paramsDic);
        }

    }
}